import Vue from 'vue'
import VueRouter from 'vue-router'
import Global from '@/layouts/GlobalSlideMenu/index'
const PagesRouter = {
  routes: [
    {
      path: '/',
      name: '首页',
      component: Global,
      // redirect: '/home',
      meta: { title: '首页' },
      children: [
        {
          name: 'tableDraw',
          icon: 'iconshujutongji',
          iconClass: 'change',
          type: 'tableSrot',
          meta: { title: '弹窗演示' },
          component: resolve => require(['@/pages/tableDraw'], resolve),
          path: '/tableDraw'
        },
        {
          name: 'tableDialog',
          icon: 'iconshujutongji',
          iconClass: 'change',
          type: 'tableSrot',
          meta: { title: '弹窗演示' },
          component: resolve => require(['@/pages/tableDialog'], resolve),
          path: '/tableDialog'
        },
        {
          name: 'tinymce',
          icon: 'iconshujutongji',
          iconClass: 'change',
          meta: { title: '富文本编辑器' },
          component: resolve => require(['@/pages/tinymce'], resolve),
          path: '/tinymce'
        },
        {
          name: 'ImagePreview',
          icon: 'iconshujutongji',
          iconClass: 'change',
          meta: { title: '图片预览' },
          component: resolve => require(['@/pages/preview-image'], resolve),
          path: '/preview-image'
        }
      ]
    },
    // 异常页面
    {
      path: '/403',
      component: () => import('@/common/components/exception/403.vue')
    },
    {
      path: '*',
      component: () => import('@/common/components/exception/404.vue')
    }
  ],
  // scroll to page top
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  }
}
Vue.use(VueRouter)
const router = new VueRouter(PagesRouter)
export default router
